#!/bin/bash
beep --help 2>/dev/null | grep Usage > /dev/null || exit 1
charge=$( cat /proc/acpi/battery/BAT0/state | grep "remaining" | cut -d":" -f2 | tr -s " " | cut -d" " -f2)
alarm=$(cat /proc/acpi/battery/BAT0/info | grep "warning:" | cut -d":" -f2 | tr -s " " | cut -d" " -f2)
state=$(cat /proc/acpi/battery/BAT0/state | grep "charging state" | tr -s " " | cut -d" " -f3)
echo $alarm $charge $state
(( $charge < $alarm )) && [[ ! "$state" = "charging" ]] && beep -f 2000 -l 2000 &

